<template>
	<view class="mine-page">
		<view class="page-title">个人中心</view>
		<view class="box main-box">
			<view class="head">
				<view class="vip">{{user.userType == 2 ? "全端版" : (user.userType == 1 ? "口袋版" : "基础版")}}</view>
				<view class="tips">每日重置</view>
			</view>
			<view class="grade-box">
				<view class="grade-item">
					<view class="grade-number">{{user.balanceDiamond}}</view>
					<view class="grade-name">
						<view class="grade-name-box">
							<image src="/static/diamond.png" style="width: 20rpx; height: 26rpx;"></image>
							<view style="font-size: 24rpx; margin-left: 20rpx;">基础积分</view>
						</view>
					</view>
				</view>
				<view class="grade-divider"></view>
				<view class="grade-item">
					<view class="grade-number">{{user.balanceStar}}</view>
					<view class="grade-name">
						<view class="grade-name-box">
							<image src="/static/star.png" style="width: 20rpx; height: 26rpx;"></image>
							<view style="font-size: 24rpx; margin-left: 20rpx;">高级积分</view>
						</view>
					</view>
				</view>
			</view>
			
		</view>
		
		<view class="share-box">
			<image src="/static/gift.png" style="width: 30rpx; height: 32rpx;"></image>
			<view class="text">积分不足？升级获得更多积分</view>
			
		</view>
		
		<view class="box nav-box" v-for="(box,i) in navItems" :key="i">
			<view v-for="(item,j) in box" :key="j">
				<view class="nav-item" @tap="navItemClick(item)">
					<image :src="item.icon" class="nav-icon"></image>
					<view class="nav-title">{{item.title}}</view>
					<image src="/static/indicator-right.png" style="width: 32rpx; height: 32rpx;"></image>
				</view>
				<view class="nav-divider" v-if="j < box.length -1"></view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { reactive } from 'vue'
	import { http } from '@/utils/request'
	import { onMounted } from 'vue'
	import { onLoad,onShow } from "@dcloudio/uni-app";
	
	
	
	
	const navItems = reactive([
		[
			{icon: '/static/my/account.png', title: "账户", action: '/pages/my/account'},
			{icon: '/static/my/assist.png', title: "智能助手", action: ''},
		],
		[
			{icon: '/static/my/chat.png', title: "聊天设置", action: ''},
		],
		[
			{icon: '/static/my/invite.png', title: "邀请", action: '/pages/common/invite'},
			// {icon: '/static/my/share.png', title: "分享", action: ''},
			{icon: '/static/my/about.png', title: "关于我们", action: '/pages/my/about'},
			{icon: '/static/my/contact.png', title: "联系我们", action: '/pages/common/feedback'},
		],
	])
	
	
	const navItemClick = (item)=>{
		if (item.action) {
			uni.navigateTo({
				url: item.action
			})
		}
	}
	
	
	const user = reactive({
		type: 0,
		balanceDiamond: 0,
		balanceStar: 0,
	})

	const getUserInfo = ()=>{
		http.request({
			url: '/app/user/login_user',
			method: 'GET'
		}).then(resp => {
			Object.assign(user, resp.data);
		})
	}
	
	onShow(()=>{
		getUserInfo();
	})
</script>

<style  lang="scss" scoped>
	.mine-page {
		position: relative;
		min-height: 500rpx;
		background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%), linear-gradient(90deg, rgba(228, 252, 182, 1) 100%, rgba(194, 253, 255, 1) 0%);
		padding-top: 88rpx;
	}
	
	
	.page-title {
		font-size: 48rpx;
		padding-left: 32rpx;
		font-weight: 500;
	}
	
	.box {
		border-radius: 16rpx;
		margin-left: 32rpx;
		margin-right: 32rpx;
	}
	
	.main-box {
		margin-top: 48rpx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
		
		.head {
			height: 112rpx;
			display: flex;
			padding-left: 32rpx;
			padding-right: 32rpx;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			border-bottom:  1rpx dashed rgba(245, 245, 245, 1);
			
			.vip {
				font-size: 36rpx;
				font-weight: 600;
				color: rgba(0, 0, 0, 1);
			}
			
			.tips {
				font-size: 24rpx;
				color: rgba(153, 153, 153, 1);
			}
		}
		
		.grade-box {
			display: flex;
			flex-direction: row;
			align-items: center;
			
			.grade-item {
				flex: 1;
				
				.grade-number {
					text-align: center;
					font-size: 48rpx;
					color: rgba(51, 51, 51, 1);
					font-weight: 900;
				}
				
				.grade-name {
					margin-top: 16rpx;
					display: flex;
					justify-content: center;
					
					.grade-name-box {
						display: flex;
						flex-direction: row;
						align-items: center;
						padding-left: 16rpx;
						padding-right: 16rpx;
						padding-top: 6rpx;
						padding-bottom: 6rpx;
						background: rgba(250, 250, 250, 1);
						border-radius: 24rpx;
					}
				}
				
			}
			
			.grade-divider {
				width: 1rpx;
				border-right: 1rpx dashed rgba(245, 245, 245, 1);
				height: 182rpx;
			}
		}
	}
	
	
	.share-box {
		background: rgba(0, 0, 0, 1);
		border-radius: 16rpx;
		margin: 32rpx 32rpx 0 32rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 80rpx;
		flex-direction: row;
		
		.text {
			color: rgba(197, 255, 89, 1);
			font-size: 32rpx;
			margin-left: 16rpx;
		}
	}
	
	
	.nav-box {
		margin-top: 32rpx;
		background: rgba(250, 250, 250, 1);
		
		.nav-item {
			height: 108rpx;
			padding-left: 30rpx;
			padding-right: 30rpx;
			display: flex;
			align-items: center;
			
			.nav-icon {
				width: 48rpx;
				height: 48rpx;
			}
			
			.nav-title {
				flex: 1;
				margin-left: 10rpx;
				margin-right: 16rpx;
			}
		}
		
		.nav-divider {
			height: 1rpx;
			border-bottom: 1rpx dashed rgba(241, 241, 241, 1);
		}
	}
</style>
